package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.hiultra.archive.domain.ArchiveBoxIllegalDetailRecords;
import com.hiultra.archive.service.IArchiveBoxIllegalDetailRecordsService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveBoxIllegalRecords;
import com.hiultra.archive.service.IArchiveBoxIllegalRecordsService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 非法携带盒记录Controller
 *
 * @author 派大星
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/archive/ArchiveBoxIllegalRecords")
public class ArchiveBoxIllegalRecordsController extends BaseController {
    @Autowired
    private IArchiveBoxIllegalRecordsService archiveBoxIllegalRecordsService;
    @Autowired
    private IArchiveBoxIllegalDetailRecordsService archiveBoxIllegalDetailRecordsService;

    /**
     * 查询非法携带盒记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveBoxIllegalRecords archiveBoxIllegalRecords) {
        startPage();
        List<ArchiveBoxIllegalRecords> list = archiveBoxIllegalRecordsService.selectArchiveBoxIllegalRecordsList(archiveBoxIllegalRecords);
        return getDataTable(list);
    }

    /**
     * 导出非法携带盒记录列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:export')")
    @Log(title = "非法携带盒记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveBoxIllegalRecords archiveBoxIllegalRecords) {
        List<ArchiveBoxIllegalRecords> list = archiveBoxIllegalRecordsService.selectArchiveBoxIllegalRecordsList(archiveBoxIllegalRecords);
        for (ArchiveBoxIllegalRecords archiveBoxIllegalRecords1 : list) {
            List<ArchiveBoxIllegalDetailRecords> archiveBoxIllegalDetailRecordsList = archiveBoxIllegalDetailRecordsService.selectArchiveBoxIllegalDetailRecordsList(new ArchiveBoxIllegalDetailRecords() {{
                setRecordId(archiveBoxIllegalRecords1.getId());
            }});
            archiveBoxIllegalRecords1.setBoxList(archiveBoxIllegalDetailRecordsList);
        }
        ExcelUtil<ArchiveBoxIllegalRecords> util = new ExcelUtil<ArchiveBoxIllegalRecords>(ArchiveBoxIllegalRecords.class);
        util.exportExcel(response, list, "非法携带盒记录数据");
    }

    /**
     * 获取非法携带盒记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(archiveBoxIllegalRecordsService.selectArchiveBoxIllegalRecordsById(id));
    }

    /**
     * 新增非法携带盒记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:add')")
    @Log(title = "非法携带盒记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveBoxIllegalRecords archiveBoxIllegalRecords) {
        return toAjax(archiveBoxIllegalRecordsService.insertArchiveBoxIllegalRecords(archiveBoxIllegalRecords));
    }

    /**
     * 修改非法携带盒记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:edit')")
    @Log(title = "非法携带盒记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveBoxIllegalRecords archiveBoxIllegalRecords) {
        return toAjax(archiveBoxIllegalRecordsService.updateArchiveBoxIllegalRecords(archiveBoxIllegalRecords));
    }

    /**
     * 删除非法携带盒记录
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBoxIllegalRecords:remove')")
    @Log(title = "非法携带盒记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(archiveBoxIllegalRecordsService.deleteArchiveBoxIllegalRecordsByIds(ids));
    }
}
